package com.ruoyi.system.mapper.media;

import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.Delete;
import org.springframework.stereotype.Repository;
import com.ruoyi.system.domain.media.MediaUser;

/**
 * 广电用户Mapper接口
 */
@Mapper
@Repository
public interface MediaUserMapper {
    /**
     * 查询广电用户
     * 
     * @param userId 广电用户ID
     * @return 广电用户
     */
    @Select("SELECT 1 as userId, '测试用户' as userName, '13800138000' as phoneNo, '测试地址' as address")
    public MediaUser selectMediaUserById(Long userId);

    /**
     * 根据手机号查询广电用户
     * 
     * @param phoneNo 手机号
     * @return 广电用户
     */
    @Select("SELECT 1 as userId, '测试用户' as userName, #{phoneNo} as phoneNo, '测试地址' as address")
    public MediaUser selectMediaUserByPhoneNo(String phoneNo);

    /**
     * 查询广电用户列表
     * 
     * @param mediaUser 广电用户
     * @return 广电用户集合
     */
    @Select("SELECT 1 as userId, '测试用户' as userName, '13800138000' as phoneNo, '测试地址' as address")
    public List<MediaUser> selectMediaUserList(MediaUser mediaUser);

    /**
     * 新增广电用户
     * 
     * @param mediaUser 广电用户
     * @return 结果
     */
    @Insert("INSERT INTO media_user (userName, phoneNo, address) VALUES (#{userName}, #{phoneNo}, #{address})")
    public int insertMediaUser(MediaUser mediaUser);

    /**
     * 修改广电用户
     * 
     * @param mediaUser 广电用户
     * @return 结果
     */
    @Update("UPDATE media_user SET userName = #{userName}, phoneNo = #{phoneNo}, address = #{address} WHERE userId = #{userId}")
    public int updateMediaUser(MediaUser mediaUser);

    /**
     * 删除广电用户
     * 
     * @param userId 广电用户ID
     * @return 结果
     */
    @Delete("DELETE FROM media_user WHERE userId = #{userId}")
    public int deleteMediaUserById(Long userId);

    /**
     * 批量删除广电用户
     * 
     * @param userIds 需要删除的数据ID
     * @return 结果
     */
    @Delete("<script>DELETE FROM media_user WHERE userId IN <foreach collection='userIds' item='userId' open='(' separator=',' close=')'>#{userId}</foreach></script>")
    public int deleteMediaUserByIds(Long[] userIds);
    
    /**
     * 批量插入广电用户
     * 
     * @param mediaUserList 广电用户列表
     * @return 结果
     */
    @Insert("INSERT INTO media_user (userName, phoneNo, address) VALUES (#{item.userName}, #{item.phoneNo}, #{item.address})")
    public int batchInsertMediaUser(List<MediaUser> mediaUserList);
}